#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //set QLabel
    ui->label->setText("Input the period");
    ui->label->setAlignment(Qt::AlignCenter);

    //set QDateTime
    ui->dateTimeEdit->setDateTime(QDateTime({2024,12,12}));
    ui->dateTimeEdit_2->setDateTime(QDateTime({2024,12,12}));
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    QDateTime beginTime = ui->dateTimeEdit->dateTime();
    QDateTime endTime = ui->dateTimeEdit_2->dateTime();

//    int outDay = beginTime.daysTo(endTime);
    int outDay = (beginTime.secsTo(endTime)/3600)/24;
    int outHour = (beginTime.secsTo(endTime)/3600)%24;

    ui->label->setText("Having love you " + QString::number(outDay) + "days "
                       + QString::number(outHour) + "hours");

}
